<template>
	<view class="main">
		<view class="navi-bar">
			<view class="navi-back" @click="goBack">
				<
			</view>
			<view class="navi-title">
				常见问题
			</view>
			<view class="navi-history">
				历史反馈
			</view>
		</view>
		<view class="faq-item">
			<view class="faq-title">
				{{FaqContentList.title}}
			</view>
			<view class="faq-content" v-html="FaqContentList.content">
				{{FaqContentList.content}}
			</view>
		</view>
		<view class="faq-btn" @click="naviTo">
			我要反馈
		</view>
	</view>
</template>

<script>
	import {
		http
	} from '../../untils/http.js'
	
	const url = 'feedback'
	
	export default {
		data() {
			return {
				FaqContentList: []
			}
		},
		onLoad({
			id
		}) {
			this.getFaqContent(id)
		},
		methods: {
			getFaqContent(id) {
				http(url).then(res => {
					// 临时数组存放数据
					let Arr = res.data.faq.questions.content
					// 根据接收的id判断是否为所需要的数据
					for (let i = 0; i < Arr.length; i++) {
						if (Arr[i].id == id) {
							console.log(Arr[i].id);
							this.FaqContentList = Arr[i]
							console.log(this.FaqContentList);
						}
					}
				})
			},
			naviTo() {
				uni.navigateTo({
					url: '/pages/FeedBackDetails/FeedBackDetails'
				})
			},
			goBack() {
				// 返回上一级并刷新当前页面
				this.$router.go(-1)
			}
		}
	}
</script>

<style lang="scss">
	* {
		box-sizing: border-box;
	}
	
	.main {
		position: relative;
		background-color: #f1f1f1;
		height: 1300rpx;
	}
	
	.navi-bar {
		padding: 0 10px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 80rpx;
		line-height: 80rpx;
		background-color: #fff;
		border-bottom: 1px solid #dadada;
		
		.navi-back {
			color: #cc2225;
		}
		
		.navi-title {
			margin-left: 20px;
			font-size: 16px;
		}
		
		.navi-history {
			font-size: 12px;
			color: #cc2225;
		}
	}
	
	.faq-item {
		margin-top: 10px;
		width: 750rpx;
		height: 400rpx;
		background-color: #fff;
	}
	
	.faq-title {
		padding: 10px;
		width: 100%;
		border-bottom: 1px solid #d8d8d8;
		font-size: 14px;
	}
	
	.faq-content {
		padding: 10px;
		font-size: 12px;
	}
	
	.faq-btn {
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		background-color: #222222;
		color: #fff;
	}
</style>
